<?php

class model_pb extends L {

    /**
     * 描述 ：分页的查询语句拼接
     * 作者 ：Zoro.Zhu
    **/
    public static function searchSql($params = array()){
        $sql = "SELECT
             `id`, `pbData`, `account`, `pbData`->>'$.campaign_name' as campaign_name,
             `pbData`->>'$.state' as state,`pbData`->>'$.updated_at' as updated_at
        FROM
            `wish_pb`
        WHERE 1";
        $dxmAccount = model_com::getAccount('wish');
        $sql .= " AND `account` IN ('" . join("','", $dxmAccount) . "')";
        $sql .= !empty($params['search']['name']) ? " AND `pbData`->>'$.campaign_name' LIKE '%{$params['search']['name']}%' " : "";
        $sql .= !empty($params['search']['state']) ? " AND `pbData` ->> '$.state' IN ( '" . join("','", $params['search']['state']) . "' ) " : "";
        $sql .= !empty($params['search']['account']) ? " AND account IN ( '" . join("','", $params['search']['account']) . "' ) " : "";
        return $sql;
    }

}